﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Barebones.Components;
using Barebones.Dependencies;
using Barebones.Framework;

namespace BareboneTests.Counters
{
    abstract class CounterComponent : EntityComponent
    {
        public int CountAdded
        { get; set; }

        public int CountRemoved
        { get; set; }

        public int CountOwnerSet
        { get; set; }

        public int CountOwnerRemoved
        { get; set; }

        public override IEnumerable<IDependency> GetDependencies()
        {
            yield return new Dependency<Object>(ComponentAdded, ComponentRemoved);
        }

        void ComponentAdded(Object item)
        {
            CountAdded++;
        }

        void ComponentRemoved(Object item)
        {
            CountRemoved++;
        }

        protected override void OnOwnerRemoved(Entity owner)
        {
            CountOwnerRemoved++;
        }

        protected override void OnOwnerSet()
        {
            CountOwnerSet++;
        }
    }
}
